import Taro from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import './index.less'
import emptyImg from '../../assets/images/ic_empty.svg'

interface IProps {
  des: string
  btnTxt: string
  onAction?: () => void
}

const onTap = () => {
  console.log(this.props)
  const { isBinding } = Taro.getStorageSync('user')
  if (isBinding === 0) {
    Taro.navigateTo({
      url: '/pages/gender/index'
    })
  } else {
    if (this.props.onAction) {
      this.props.onAction()
    }
    // this.$emit('action')
  }
}

const Index = (props: IProps) => {
  const { des, btnTxt } = props
  return (
    <View className="empty">
      <Image src={emptyImg} className="ic-empty" />
      <View className="des">{des}</View>
      <View className="content">
        {btnTxt ? (
          <View className="btn icon icon-xiezuo" hoverClass="btn-hover" onClick={onTap}>
            {btnTxt}
          </View>
        ) : null}
      </View>
    </View>
  )
}

export default Index
